package cn.fzm.springmvc.controller;

import cn.fzm.springmvc.domain.Account;
import cn.fzm.springmvc.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Dremeue
 * @create 2019-09-29 19:09
 **/
@Controller
@RequestMapping("/param")
public class ParamController {

    /**
     * 绑定字符串类型
     *
     * @return
     */
    @RequestMapping("/testBindString")
    public String testBindString(String username, String password) {
        System.out.println("执行了...");
        System.out.println("用户名: " + username);
        System.out.println("密码: " + password);
        return "success";
    }

    /**
     * 绑定JavaBean类型1
     *
     * @return
     */
    @RequestMapping("/testBindJavaBean")
    public String testBindJavaBean(Account account) {
        System.out.println("执行了...");
        System.out.println(account);
        return "success";
    }

    /**
     * 绑定javabean类型2 - javabean中包含其他引用类型
     *
     * @return
     */
    @RequestMapping("/testBindJavaBean2")
    public String testBindJavaBean2(Account account) {
        System.out.println("执行了...");
        System.out.println(account);
        return "success";
    }

    /**
     * 绑定javabean类型3 - javabean中包含list或map
     *
     * @return
     */
    @RequestMapping("/testBindJavaBean3")
    public String testBindJavaBean3(Account account) {
        System.out.println("执行了...");
        System.out.println(account);
        return "success";
    }

    @RequestMapping("/testConverter")
    public String testConverter(User user){
        System.out.println("执行了...");
        System.out.println(user);
        return "success";
    }
}
